package com.aw.baselib.base

import com.aw.baselib.bean.CommonListBean

/**
 * Created by hzw
 */
class AwResponseBean<T> : CommonListBean() {
    var msg: String? = null
    var data: T? = null
        private set
    var message: String? = null
    var code = -1
    fun setData(data: T) {
        this.data = data
    }

    val isSuccess: Boolean
        get() = code == CODE_SUCCESS
    val isTokenError: Boolean
        get() = code == CODE_TOKEN_ERROR

    override fun toString(): String {
        return "AwResponseBean{" +
                "msg='" + msg + '\'' +
                ", data=" + data +
                ", message='" + message + '\'' +
                ", code=" + code +
                '}'
    }

    companion object {
        private const val CODE_SUCCESS = 0
        private const val CODE_TOKEN_ERROR = 401
    }
}